/*
 * This file is part of ELCube.
 *
 * ELCube is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ELCube is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with ELCube.  If not, see <https://www.gnu.org/licenses/>.
 */
package cn.nkpro.elcube.docengine.service.impl;

import cn.nkpro.elcube.annotation.NkNote;
import cn.nkpro.elcube.docengine.EnumDocClassify;
import cn.nkpro.elcube.docengine.NkDocCycle;
import cn.nkpro.elcube.docengine.gen.DocH;
import cn.nkpro.elcube.docengine.model.DocDefHV;
import cn.nkpro.elcube.docengine.model.DocHBasis;
import cn.nkpro.elcube.docengine.model.DocHV;
import cn.nkpro.elcube.docengine.model.DocPipeline;
import cn.nkpro.elcube.docengine.model.event.DocCreateEvent;
import cn.nkpro.elcube.utils.BeanUtilz;
import cn.nkpro.elcube.utils.DateTimeUtilz;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;

@Order(2)
@NkNote("流水线")
@Component("NkDocPipelineProcessor")
public class NkDocPipelineProcessor extends NkDocTransactionProcessor {
    @Override
    public EnumDocClassify classify() {
        return EnumDocClassify.PIPELINE;
    }

    @Override
    public String desc() {
        return "Pipeline | 流水线";
    }

    @Override
    DocHV instantiateDoc(DocHBasis basis, boolean forceCopy) {
        if(basis==null){
            return new DocPipeline();
        }
        if(!forceCopy && basis instanceof DocPipeline){
            return (DocPipeline) basis;
        }
        return BeanUtilz.copyFromObject(basis,DocPipeline.class);
    }
}
